package q1.project.core.jpa.config;

import java.util.Collections;
import java.util.Map;
import org.hibernate.jpa.boot.spi.IntegratorProvider;
import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer;
import org.springframework.stereotype.Component;

/**
 * Hibernate 配置类 配套 @Comment 注解使用，自动注册 CommentIntegrator
 *
 * @author Q1 Team
 * @version 1.0
 */
@Component
public class HibernateConfig implements HibernatePropertiesCustomizer {

  @Override
  public void customize(Map<String, Object> hibernateProperties) {
    // 启用SQL注释
    hibernateProperties.put("hibernate.use_sql_comments", true);
    // 注册Comment注解集成器
    hibernateProperties.put(
        "hibernate.integrator_provider",
        (IntegratorProvider) () -> Collections.singletonList(CommentIntegrator.INSTANCE));
  }
}
